<template>
    <div>
        <van-field v-model="form.name" label='手机号'/>
        <van-field v-model="form.password" label='密码'/>
   
        角色:
        <select v-model="form.role_id">
            <option :value="i.id" v-for="i in role">{{i.name}}</option>
        </select>
        
        <van-button @click="add" color="linear-gradient(to right, #ff6034,#7232dd)">添加</van-button>
    </div>
</template>

<script>
    export default {
        data(){
            return{
                form:{},
                role:[],
                mobile:'',
            }
        },
        methods:{
            ree(){
                this.mobile=/^1{3,9}[9]$/
            },
            getrole(){
                this.$axios.get('roleM').then(res=>{
                    this.role = res.data.list
                })
            },
            add(){
                this.$axios.post('users',this.form).then(res=>{
                        alert('添加成功')
                })
            }
        },
        mounted(){
            this.getrole()
        }
    }
</script>

<style scoped>

</style>